package com.example.httputil;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.example.domain.User;

public class GetRegJson {
	public static List<User> getJsonUserList(InputStream inStream) throws Exception{
		List<User> userlist = new ArrayList<User>();		
		byte[] data = StreamTool.read(inStream);  
		String json = new String(data);
		JSONObject jsonobject = new JSONObject(json);
		JSONArray userarray = jsonobject.getJSONArray("list");
		JSONObject statobject = jsonobject.getJSONObject("status");	
		Integer status = statobject.getInt("status");
		if(status == 0){
			for(int i = 0;i<userarray.length();i++){
				JSONObject item = userarray.getJSONObject(i);

				String userName = item.getString("userName");
				Integer ifDelete = item.getInt("ifDelete");
				String email = item.getString("email");
				String password = item.getString("password");
				String headImg = item.getString("headImg");
				Integer sex = item.getInt("sex");
				String say = item.getString("say");
				String birthday = item.getString("birthday");
				Integer grade = item.getInt("grade");
				String qq = item.getString("qq");
				String regionUuid = item.getString("regionUuid");
				String rankPoints = item.getString("rankPoints");
				String mobile = item.getString("mobile");
				String machineSn = item.getString("machineSn");
				String bpw = item.getString("bpw");
//				userlist.add(new  AppUser(userName,  ifDelete,  email,
//						 password,  headImg,  sex,  say,
//						 birthday,  grade, qq,
//						 regionUuid,  rankPoints,  mobile,
//						 machineSn,  bpw));	
			}
		}else{
			return null;
		}
	
	return userlist;
}
}
